﻿namespace Pibby.Core.Playlist
{
    using System;
    using System.Collections.ObjectModel;

	public class PlaylistItem : Identifiable
	{
		public PlaylistItem()
			: base ()
		{
		}

		public PlaylistItem (string path)
			: this ()
		{
			this.Path = path;
		}

		public PlaylistItem(string path, string id)
			: base (id)
		{
			this.Path = path;
		}

		public string Path
		{
			get;
			set;
		}

		public string RelativePathTo(string baseFolder)
		{
			if (string.IsNullOrEmpty(baseFolder))
				throw new ArgumentNullException("baseFolder", "Path cannot be blank");

			if (this.Path.StartsWith(baseFolder))
			{
				if (baseFolder[baseFolder.Length - 1] != System.IO.Path.DirectorySeparatorChar)
					baseFolder = baseFolder + System.IO.Path.DirectorySeparatorChar;

				return this.Path.Replace(baseFolder, string.Empty);
			}

			return this.Path;
		}
	}
}
